Skip to main content

gitignore FIle

.gitignore forces files to be untracked. Files that we do not want to share are described inside .gitignore.

Place the .gitignore file in your root directory.

Examples

  • ignore.txt → Ignore the ignore.txt file
  • *.txt → Ignore all files with the .txt extension
  • temp/ → Ignore the temp folder
  • !main.txt → Do not ignore main.txt (exception rule)
  • ignore?.txt → Ignore files like ignore1.txt, ignore2.txt, ignoreA.txt (matches exactly one character after ignore)
  • ignore????.txt → Ignore files starting with ignore followed by exactly 5 characters
  • ignore*.txt → Ignore all files starting with ignore

Notes

  • git status displays the working directory and staging area (tracked and untracked files).
  • You can check whether .gitignore is working using git status.
  • If it's working, some files will appear as untracked.
  • When creating a new repository, there is an option to add a .gitignore file.
  • You can select a .gitignore template based on your application (e.g., Node, Android, etc.).